'''
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT license.

dataFileTemplate.py has the template for data.h 
DO NOT MODIFY THIS

'''
def populateDataFileTemplate(valueDict):
    gamma = valueDict['gamma']
    featDim = valueDict['featDim']
    ldDim = valueDict['ldDim']
    ldProjectionMatrix = valueDict['ldProjectionMatrix']
    numPrototypes = valueDict['numPrototypes']
    prototypeMatrix = valueDict['prototypeMatrix']
    numLabels = valueDict['numLabels']
    prototypeLabelMatrix = valueDict['prototypeLabelMatrix']
    
    template = '''/*
 * This is an autogenerated file. Modifications
 * might not be persistent.
 */
namespace protoNNParam {

#ifndef __TEST_PROTONN__
    /** Gamma for gaussian kernel */
    const PROGMEM float gamma = %s;
    /** Low Dimensional Projection Matrix */
    const PROGMEM unsigned int featDim = %s;
    const PROGMEM unsigned int ldDim = %s;

    /**
    * Projectino Matrix (W)
    * d_cap x d flattened (dimension of 2D array)
    * ldDim x featDim
    */
    const PROGMEM  float ldProjectionMatrix[]  = {%s};
    ''' % (gamma, featDim, ldDim, ldProjectionMatrix)

    template += '''
    /**
     * Prototypes (B)
     * m x d_cap flattened (dimension of 2D array)
     * numPrototypes x d_cap
     */
    const PROGMEM float prototypeMatrix[] = {%s};
    /** Number of prototypes (m) */
    const PROGMEM unsigned int numPrototypes = %s;
    ''' % (prototypeMatrix, numPrototypes)

    template += '''
    /**
     * Prototype Lables (Z)
     * m x L (dimension of 2D array)
     * numLabels x numPrototypes
     */
    const PROGMEM float prototypeLabelMatrix[] = {%s};
    /** Number of output labels, (L). */
    const PROGMEM unsigned int numLabels = %s; // 0,1,2,3,4,5
    ''' % (prototypeLabelMatrix, numLabels)

    template += '''
#else
    const PROGMEM float = 1.0;
    const PROGMEM unsigned int featDim = 10;
    const PROGMEM unsigned int ldDim = 5;
    // Row Major (X.x)
    const PROGMEM  float ldProjectionMatrix[]  = {
        0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,
        1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,
        2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,
        3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,
        4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,
    };
    // Column Major
    const PROGMEM unsigned int numPrototypes = 3;
    const PROGMEM float prototypeMatrix[] = {
        -1.0,-0.5,0.0,0.5,1.0,
        -2.0,-1.0,0.0,1.0,2.0,
        -7.51,-7.51,-7.51,-7.51,-7.51,
    };
    // column major
    const PROGMEM unsigned int numLabels = 4;
    const PROGMEM float prototypeLabelMatrix[] = {
        0.96,0.01,0.01,0.02,
        0.02,0.94,0.02,0.02,
        0.10,0.15,0.55,0.20,
    };
#endif
};
    '''
    return template
